package com.amado.course50java8;

import java.util.Optional;
import java.util.function.Supplier;

import com.amado.course50java8.vo.Goods;
import com.amado.course50java8.vo.GoodsCate;

public class Java806Optional4OrElseGet {

	public static void main(String[] args) {
		Goods goodsTwo = new Goods(new GoodsCate());
		getBrandNameByJava8Two(goodsTwo);
	}

	// javai optional
	public static String getBrandNameByJava8Two(Goods goods) {
//		return Optional.ofNullable(goods).map((t) -> t.getGoodsCate()).map((t) -> t.getGoodsBrand())
//				.map((t) -> t.getBrandName())
//				.orElseThrow(() -> new IllegalArgumentException("The value of param comp isn't available."));
		return Optional.ofNullable(goods).map(t -> t.getGoodsCate()).map(t -> t.getGoodsBrand())
				.map(t -> t.getBrandName()).orElseGet(() -> {
					return new String("sss").substring(1, 3);
				});

	}

}
